<template>
	<view class="container">
		<skeletons :loading="!poster.path" :rowsHeight="['90vh']">
			<image style="width: 100%;" :src="poster.path" mode="widthFix"></image>
		</skeletons>
		
		<!-- 工作室推广码 -->
		<template v-if="poster.currentPoster==1">
			<lPainter isCanvasToTempFilePath @success="poster.getImg" hidden>
				<lPainterView
					css="width: 680rpx; background: linear-gradient( 105deg, #FF7D9E 0%, #FFB796 100%);border-radius: 48rpx 48rpx 48rpx 48rpx;paddingBottom:32rpx">
					<lPainterView
						css="background: #fff;width: 622rpx;margin:134rpx auto 0;border-radius: 40rpx 40rpx 0rpx 0rpx;">

						<lPainterImage :src="poster.detail.avatar"
							css="width: 200rpx; height: 200rpx;border-radius:50%;overflow: hidden;marginTop:-100rpx;marginLeft:211rpx" />

						<lPainterView css="textAlign:center;marginBottom:16rpx;marginTop:24rpx"><l-painter-text
								:text="poster.detail.name" css="fontSize:48rpx;line-clamp:1;" />
						</lPainterView>
						<lPainterView css="textAlign:center;marginBottom:16rpx"><l-painter-text text="来我的陪宠师工作室看看吧～"
								css="fontSize:30rpx;line-clamp:1;color:#5C5E5E" />
						</lPainterView>
						<lPainterView css="textAlign:center;marginTop:62rpx;marginBottom:32rpx">
							<!-- #ifdef MP-TOUTIAO -->
							<lPainterQrcode
								:text="`${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&data1=${poster.detail.studioId}&text=dy&type=3`"
								css="width: 400rpx; height: 400rpx" />
							<!-- #endif -->
							<!-- #ifndef MP-TOUTIAO -->
							<lPainterQrcode
								:text="`${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&data1=${poster.detail.studioId}&text=wx&type=3`"
								css="width: 400rpx; height: 400rpx" />
							<!-- #endif -->

						</lPainterView>
						<!-- #ifdef MP-TOUTIAO -->
						<lPainterView css="textAlign:center;marginBottom:16rpx"><l-painter-text text="保存图片到相册 → 打开抖音APP
						 → 搜索扫一扫进行扫码" css="fontSize:24rpx;color:#5C5E5E" />
						</lPainterView>
						<!-- #endif -->
						<!-- #ifndef MP-TOUTIAO -->
						<lPainterView css="textAlign:center;marginBottom:16rpx"><l-painter-text text="保存图片到相册 → 打开微信APP
						 → 搜索扫一扫进行扫码" css="fontSize:24rpx;color:#5C5E5E" />
						</lPainterView>
						<!-- #endif -->
					</lPainterView>
					<lPainterView
						css="background: #FEE6EB;width: 622rpx;height:64rpx;border-radius:0rpx 0rpx 40rpx 40rpx;margin:0 auto;textAlign:center;paddingTop:26rpx ">
						<lPainterImage src="https://xjs-oss-prod.oss-cn-shenzhen.aliyuncs.com/xjs-static/icon-14.png"
							css="width: 240rpx; height: 24rpx;" />
					</lPainterView>
				</lPainterView>
			</lPainter>
		</template>
		<!-- 陪宠师招募码 -->
		<template v-if="poster.currentPoster==2">
			<lPainter isCanvasToTempFilePath @success="poster.getImg" hidden>
				<lPainterView css="background: #fff;width: 680rpx;">
					<lPainterImage :src="poster.detail.recruitSharePoster" css="width: 680rpx;" />
					<lPainterView css="padding:32rpx;display:flex;justify-content: space-between;">
						<lPainterView css="height: 160rpx;display:flex;flex-direction: column;
						justify-content: space-between;
				">
							<lPainterView css="width:400rpx"><l-painter-text :text="`${poster.detail.name}`"
									css="fontSize:36rpx;line-clamp:1;font-weight:bold" />
							</lPainterView>
							<lPainterView><l-painter-text text="成为陪宠师，获得劳务报酬" css="fontSize:30rpx;" />
							</lPainterView>
							<lPainterView><l-painter-text text="立即扫码/长按识别领取>>>" css="color:#7C807F;fontSize:24rpx;" />
							</lPainterView>
						</lPainterView>
						<!-- #ifdef MP-TOUTIAO -->
						<lPainterQrcode
							:text="`${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&data1=${poster.detail.studioId}&text=dy&type=1`"
							css="width: 160rpx; height: 160rpx" />
						<!-- #endif -->
						<!-- #ifndef MP-TOUTIAO -->
						<lPainterQrcode
							:text="`${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&data1=${poster.detail.studioId}&text=wx&type=1`"
							css="width: 160rpx; height: 160rpx" />
						<!-- #endif -->
					</lPainterView>
				</lPainterView>
			</lPainter>
		</template>
		<!-- 工作室推广码 -->
		<template v-if="poster.currentPoster==3">
			<lPainter isCanvasToTempFilePath @success="poster.getImg" hidden>
				<lPainterView
					css="width: 680rpx; background: linear-gradient( 105deg, #FF7D9E 0%, #FFB796 100%);border-radius: 48rpx 48rpx 48rpx 48rpx;paddingBottom:32rpx">
					<lPainterView
						css="background: #fff;width: 622rpx;margin:134rpx auto 0;border-radius: 40rpx 40rpx 0rpx 0rpx;">
		
						<lPainterImage :src="poster.detail.avatar"
							css="width: 200rpx; height: 200rpx;border-radius:50%;overflow: hidden;marginTop:-100rpx;marginLeft:211rpx" />
		
						<lPainterView css="textAlign:center;marginBottom:16rpx;marginTop:24rpx"><l-painter-text
								:text="poster.petsitterTeamVo.nickName" css="fontSize:48rpx;line-clamp:1;" />
						</lPainterView>
						<lPainterView css="textAlign:center;marginBottom:16rpx;marginTop:24rpx"><l-painter-text
								:text="poster.detail.name" css="fontSize:36rpx;line-clamp:1;" />
						</lPainterView>
						<lPainterView css="textAlign:center;marginBottom:16rpx"><l-painter-text text="扫码下单，我将为您提供陪宠服务"
								css="fontSize:30rpx;line-clamp:1;color:#5C5E5E" />
						</lPainterView>
						<lPainterView css="textAlign:center;marginBottom:16rpx"><l-painter-text :text="poster.petsitterTeamVo.petsitterIntroduce"
								css="fontSize:26rpx;line-clamp:1;color:#5C5E5E" />
						</lPainterView>
						<lPainterView css="textAlign:center;marginTop:62rpx;marginBottom:32rpx">
							<!-- #ifdef MP-TOUTIAO -->
							<lPainterQrcode
								:text="`${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&data1=${poster.detail.studioId}&text=dy&type=3`"
								css="width: 400rpx; height: 400rpx" />
							<!-- #endif -->
							<!-- #ifndef MP-TOUTIAO -->
							<lPainterQrcode
								:text="`${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&data1=${poster.detail.studioId}&text=wx&type=3`"
								css="width: 400rpx; height: 400rpx" />
							<!-- #endif -->
		
						</lPainterView>
						<!-- #ifdef MP-TOUTIAO -->
						<lPainterView css="textAlign:center;marginBottom:16rpx"><l-painter-text text="保存图片到相册 → 打开抖音APP
						 → 搜索扫一扫进行扫码" css="fontSize:24rpx;color:#5C5E5E" />
						</lPainterView>
						<!-- #endif -->
						<!-- #ifndef MP-TOUTIAO -->
						<lPainterView css="textAlign:center;marginBottom:16rpx"><l-painter-text text="保存图片到相册 → 打开微信APP
						 → 搜索扫一扫进行扫码" css="fontSize:24rpx;color:#5C5E5E" />
						</lPainterView>
						<!-- #endif -->
					</lPainterView>
					<lPainterView
						css="background: #FEE6EB;width: 622rpx;height:64rpx;border-radius:0rpx 0rpx 40rpx 40rpx;margin:0 auto;textAlign:center;paddingTop:26rpx ">
						<lPainterImage src="https://xjs-oss-prod.oss-cn-shenzhen.aliyuncs.com/xjs-static/icon-14.png"
							css="width: 240rpx; height: 24rpx;" />
					</lPainterView>
				</lPainterView>
			</lPainter>
		</template>
		<!-- 考试证书 -->
		<template v-if="poster.currentPoster==4">
			<lPainter isCanvasToTempFilePath @success="poster.getImg" hidden>
				<lPainterView css="background: #fff;width: 680rpx;">
					<lPainterImage :src="poster.imageUrl" css="width: 680rpx;" />
				</lPainterView>
			</lPainter>
		</template>
		<!-- 服务详情 -->
		<template v-if="poster.currentPoster==5">
			<lPainter isCanvasToTempFilePath @success="poster.getImg" hidden>
				<lPainterView
					css="width: 680rpx; background: linear-gradient( 105deg, #FF7D9E 0%, #FFB796 100%);border-radius: 48rpx 48rpx 48rpx 48rpx;paddingBottom:32rpx">
					<lPainterView
						css="background: #fff;width: 622rpx;margin:134rpx auto 0;border-radius: 40rpx 40rpx 0rpx 0rpx;">
						<lPainterView css="width: 558rpx;marginBottom:16rpx;marginTop:24rpx;marginLeft:32rpx;display:flex;alignItems:center;boxSizing:border-box;">
							<lPainterImage :src="userInfo.avatar" css="width: 60rpx; height: 60rpx;border-radius:50%;overflow: hidden;marginRight:16rpx" />
							<l-painter-text :text="'您的好友'+userInfo.nickName+'向您推荐了该商品'" css="width:482rpx;fontSize:26rpx;line-clamp:2;" />
						</lPainterView>
						<lPainterImage :src="poster.detail.goods.thumPic" css="width: 558rpx; height:360rpx;overflow: hidden;marginLeft:32rpx" />
						<lPainterView css="marginBottom:16rpx;marginTop:32rpx;marginLeft:32rpx;display:flex;alignItems:flex-start;justifyContent:space-between;">
							<lPainterView>
								<lPainterView css="textAlign:left;marginBottom:32rpx;"><l-painter-text
										:text="poster.detail.goods.name" css="fontSize:36rpx;line-clamp:2;" />
								</lPainterView>
								<lPainterView css="textAlign:left;marginBottom:16rpx;"><l-painter-text
										:text="'¥'+poster.detail.goodsSkuList[0].price+'起'" css="fontSize:30rpx;line-clamp:2;" />
								</lPainterView>
							</lPainterView>
							<lPainterView css="textAlign:center;marginBottom:32rpx;marginRight:32rpx">
								<!-- #ifdef MP-TOUTIAO -->
								<lPainterQrcode
									:text="`${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&data1=${posterAll.poster_5.id}&studioId=${posterAll.poster_5.studioId}&text=dy&type=5`"
									css="width: 200rpx; height: 200rpx" />
								<!-- #endif -->
								<!-- #ifndef MP-TOUTIAO -->
								<lPainterQrcode
									:text="`${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&data1=${posterAll.poster_5.id}&studioId=${posterAll.poster_5.studioId}&text=wx&type=5`"
									css="width: 200rpx; height: 200rpx" />
								<!-- #endif -->
								<lPainterView css="textAlign:center;marginTop:16rpx"><l-painter-text
										:text="'长按识别或扫码购买'" css="fontSize:24rpx;" />
								</lPainterView>				
							</lPainterView>
						</lPainterView>
						
					</lPainterView>
					<lPainterView
						css="background: #fff;width: 622rpx;height:80rpx;border-radius:0rpx 0rpx 40rpx 40rpx;margin:0 auto;display:flex;alignItems:center;">
						<lPainterImage :src="poster.detail.studio.avatar" css="width: 60rpx; height: 60rpx;overflow: hidden;marginRight:16rpx;marginLeft:32rpx" />
						<l-painter-text :text="poster.detail.studio.name" css="fontSize:26rpx;line-clamp:2;" />
					</lPainterView>
				</lPainterView>
			</lPainter>
		</template>
		<!-- 商品详情 -->
		<template v-if="poster.currentPoster==6">
			<lPainter isCanvasToTempFilePath @success="poster.getImg" hidden>
				<lPainterView
					css="width: 680rpx; background: #fff;paddingBottom:32rpx">
					<lPainterView
						css="background: #fff;width: 670rpx;margin:32rpx auto;">
						<lPainterView css="width: 670rpx;marginBottom:32rpx;marginLeft:32rpx;display:flex;alignItems:center;boxSizing:border-box;">
							<lPainterImage :src="userInfo.avatar" css="width: 60rpx; height: 60rpx;border-radius:50%;overflow: hidden;marginRight:16rpx" />
							<l-painter-text :text="'您的好友'+userInfo.nickName+'向您推荐了该商品'" css="width:530rpx;fontSize:26rpx;line-clamp:2;" />
						</lPainterView>
						<lPainterImage :src="poster.detail.thumPic" css="width: 670rpx; height:670rpx;overflow: hidden;" />
						<lPainterView css="marginBottom:16rpx;marginTop:32rpx;marginLeft:32rpx;display:flex;alignItems:flex-start;justifyContent:space-between;">
							<lPainterView>
								<lPainterView css="textAlign:left;marginBottom:32rpx;width:340rpx"><l-painter-text
										:text="poster.detail.name" css="fontSize:36rpx;line-clamp:2;" />
								</lPainterView>
								<lPainterView css="textAlign:left;marginBottom:16rpx;"><l-painter-text
										:text="'¥'+poster.detail.goodsSkuStockList[0].price" css="fontSize:30rpx;line-clamp:2;color:#FF6084" />
								</lPainterView>
							</lPainterView>
							<lPainterView css="textAlign:center;marginBottom:32rpx;marginRight:32rpx">
								<!-- #ifdef MP-TOUTIAO -->
								<lPainterQrcode
									:text="`${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&goodsId=${posterAll.poster_6.id}&text=dy&type=10`"
									css="width: 200rpx; height: 200rpx" />
								<!-- #endif -->
								<!-- #ifndef MP-TOUTIAO -->
								<lPainterQrcode
									:text="`${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&goodsId=${posterAll.poster_6.id}&text=wx&type=10`"
									css="width: 200rpx; height: 200rpx" />
								<!-- #endif -->
								<lPainterView css="textAlign:center;marginTop:16rpx"><l-painter-text
										:text="'长按识别或扫码购买'" css="fontSize:24rpx;" />
								</lPainterView>				
							</lPainterView>
						</lPainterView>
						
					</lPainterView>
					<lPainterView
						css="background: #fff;width: 670rpx;height:80rpx;border-radius:0rpx 0rpx 40rpx 40rpx;margin:0 auto;display:flex;alignItems:center;">
						<lPainterImage :src="poster.detail.brandsLogo" css="width: 60rpx; height: 60rpx;overflow: hidden;marginRight:16rpx;marginLeft:32rpx;border-radius:50%;" />
						<l-painter-text :text="poster.detail.brandsName" css="width:530rpx;fontSize:26rpx;line-clamp:2;" />
					</lPainterView>
				</lPainterView>
			</lPainter>
		</template>
		<!-- 首页 -->
		<template v-if="poster.currentPoster==7">
			<lPainter isCanvasToTempFilePath @success="poster.getImg" hidden>
				<lPainterView
					css="width: 680rpx; background: #fff;paddingBottom:32rpx">
					<lPainterView
						css="background: #fff;width: 670rpx;margin:32rpx auto;">
						<lPainterImage :src="poster.detail.sharePic" css="width: 670rpx; height:500rpx;overflow: hidden;" />
						<lPainterView css="marginBottom:16rpx;marginTop:32rpx;marginLeft:24rpx;display:flex;alignItems:flex-start;justifyContent:space-between;">
							<lPainterView css="width: 670rpx;marginBottom:32rpx;marginLeft:24rpx;marginTop:48rpx;display:flex;alignItems:center;boxSizing:border-box;">
								<lPainterImage :src="userInfo.avatar" css="width: 80rpx; height: 80rpx;border-radius:50%;overflow: hidden;marginRight:16rpx" />
								<lPainterView>
									<l-painter-text :text="userInfo.nickName" css="width:530rpx;fontSize:26rpx;line-clamp:2;" />
									<lPainterView><l-painter-text :text="poster.detail.shareTitle" css="width:530rpx;fontSize:26rpx;line-clamp:2;marginTop:12rpx;" /></lPainterView>
								</lPainterView>
							</lPainterView>
							<lPainterView css="textAlign:center;marginBottom:32rpx;marginRight:32rpx">
								<!-- #ifdef MP-TOUTIAO -->
								<lPainterQrcode
									:text="`${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&text=dy&type=12`"
									css="width: 200rpx; height: 200rpx" />
								<!-- #endif -->
								<!-- #ifndef MP-TOUTIAO -->
								<lPainterQrcode
									:text="`${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&text=wx&type=12`"
									css="width: 200rpx; height: 200rpx" />
								<!-- #endif -->
								<lPainterView css="textAlign:center;marginTop:16rpx"><l-painter-text
										:text="'长按识别或扫码购买'" css="fontSize:24rpx;" />
								</lPainterView>				
							</lPainterView>
						</lPainterView>
						
					</lPainterView>
					
				</lPainterView>
			</lPainter>
		</template>
		<view v-if="poster.path" class="container">
			<view class="share-panel">
				<template v-for="(item, index) in poster.shareItems" :key="index">
					<view class="share-item" v-if="poster.showBtn.includes(item.action)">
						<view class="icon-wrapper">
							<image @click="handleShare(item)" :src="item.icon" mode=""></image>
						</view>
						<text @click="handleShare(item)" class="share-text">{{ item.text }}</text>
						<button v-if="item.action == 'wechat'" class="share-button" open-type="share"></button>
					</view>
				</template>
			</view>
		</view>
	</view>

</template>

<script lang="ts" setup>
	import { accredit } from '@/hooks/useAppPermission/index';
	import { getLocation } from "@/hooks/useFunction";
	import { onLoad, onShareAppMessage } from '@dcloudio/uni-app'
	import { ref, reactive } from 'vue'
	import { permissionGet } from '@/hooks/usePermission/index';
	import api from '@/api'
	import config from '@/config'
	import { useUserStoreToRefs } from '@/store/useUserStore'
	const { shareRefereeId,userInfo } = useUserStoreToRefs()
	import lPainter from '@/pages/share/uni_modules/lime-painter/components/l-painter/l-painter.vue'
	import lPainterView from '@/pages/share/uni_modules/lime-painter/components/l-painter-view/l-painter-view.vue'
	import lPainterImage from '@/pages/share/uni_modules/lime-painter/components/l-painter-image/l-painter-image.vue'
	import lPainterText from '@/pages/share/uni_modules/lime-painter/components/l-painter-text/l-painter-text.vue'
	import lPainterQrcode from '@/pages/share/uni_modules/lime-painter/components/l-painter-qrcode/l-painter-qrcode.vue'

	onLoad(async (data) => {
		poster.path = ""
		let titleText = ''
		if(data.type==1){
			titleText = '工作室推广码'
		}else if(data.type==2){
			titleText = '陪宠师招募码'
		}else if(data.type==3){
			titleText = '个人主页'
		}else if(data.type==4){
			posterAll.poster_4.id = data.id
			titleText = '考试证书'
		}else if(data.type==5){
			posterAll.poster_5.id = data.id
			posterAll.poster_5.studioId = data.studioId
			titleText = '分享海报'
		}else if(data.type==6){
			posterAll.poster_6.id = data.id
			titleText = '商品详情海报'
		}else if(data.type==7){
			posterAll.poster_7.id = data.id
			titleText = '分享海报'
		}
		uni.setNavigationBarTitle({
			title: titleText
		})
		poster.showBtn = posterAll[`poster_${data.type}`].showBtn || ['wechat', 'timeline', 'save']
		await posterAll[`poster_${data.type}`].getDetail()
		poster.currentPoster = data.type
		uni.showLoading({
			mask: true,
			title: '海报生成中'
		})
	})
	let shareMsg = reactive({
		title: "",
		path: "",
		imageUrl: ""
	})
	onShareAppMessage(() => {
		return shareMsg
	})
	//处理各类海报信息并统一赋值给poster对象
	const posterAll = reactive({
		poster_1: {
			showBtn: ['save', 'wechat'],
			getDetail: async () => {
				const res : any = await api({
					method: 'get',
					url: `/mall/studio/myStudio`
				})
				poster.detail = res.data.studio
				poster.detail.shareRefereeId = res.data.studioBalance.userId
				poster.detail.studioId = res.data.studioBalance.studioId
				let desc = ""
				if (poster.detail.introduce) {
					desc = poster.detail.introduce.length > 11 ? (poster.detail.introduce.slice(0, 10) + '...') : poster.detail.introduce
				}
				shareMsg.title = `${poster.detail.name}-${desc}`
				let cans = `${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&data1=${poster.detail.studioId}&text=wx&type=3`
				shareMsg.path = `/pages/shareRefereeId/index?q=${encodeURIComponent(cans)}`
				shareMsg.imageUrl = poster.detail.avatar


			}
		},
		poster_2: {
			showBtn: ['save', 'wechat'],
			getDetail: async () => {
				const res : any = await api({
					method: 'get',
					url: `/mall/studio/myStudio`
				})
				const res2 : any = await api({
					method: 'get',
					url: `/mall/content/backend-configs/getHomeConfig`
				})
				res.data.studio.recruitSharePoster = res2.data['xjs.content.contentConfig.recruitSharePoster']
				poster.detail = res.data.studio
				poster.detail.shareRefereeId = res.data.studioBalance.userId
				poster.detail.studioId = res.data.studioBalance.studioId

				shareMsg.title = `${poster.detail.name}邀您成为TA的陪宠师`
				let cans = `${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&data1=${poster.detail.studioId}&text=wx&type=1`
				shareMsg.path = `/pages/shareRefereeId/index?q=${encodeURIComponent(cans)}`
				shareMsg.imageUrl = poster.detail.avatar
			}
		},
		poster_3: {
			showBtn: ['save', 'wechat'],
			getDetail: async () => {
				const res : any = await api({
					method: 'get',
					url: `/mall/studio/myStudio`
				})
				poster.petsitterTeamVo = res.data.petsitterTeamVo
				poster.detail = res.data.studio
				poster.detail.shareRefereeId = res.data.studioBalance.userId
				poster.detail.studioId = res.data.studioBalance.studioId
				let desc = ""
				if (poster.detail.introduce) {
					desc = poster.detail.introduce.length > 11 ? (poster.detail.introduce.slice(0, 10) + '...') : poster.detail.introduce
				}
				shareMsg.title = `${poster.detail.name}-${desc}`
				let cans = `${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&data1=${poster.detail.studioId}&text=wx&type=2`
				shareMsg.path = `/pages/shareRefereeId/index?q=${encodeURIComponent(cans)}`
				shareMsg.imageUrl = poster.detail.avatar
			}
		},
		poster_4: {
			id:"",
			showBtn: ['save', 'wechat'],
			getDetail: async () => {
				const res : any = await api({
					method: 'get',
					url: `/mall/exam/exam-record/info/${posterAll.poster_4.id}`
				})
				poster.imageUrl = res.data.certificate
				poster.detail.studioId = res.data.joinedStudioId
				poster.detail.shareRefereeId = res.data.userId
				let cans = `${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&data1=${poster.detail.studioId}&text=wx&type=2`
				shareMsg.path = `/pages/shareRefereeId/index?q=${encodeURIComponent(cans)}`
				shareMsg.imageUrl = poster.detail.avatar
			}
		},
		poster_5: {
			showBtn: ['save', 'wechat'],
			id:'',
			studioId:'',
			getDetail: async () => {
				const res1: any = await getLocation();
				const res: any = await api({
					method: "get",
					url: `/mall/goods/studio-goods/info/v2?id=${posterAll.poster_5.id}&studioId=${posterAll.poster_5.studioId}`,
					data: {
						longitudes: res1.longitude,
						latitudes: res1.latitude
					}
				});
				poster.detail = res.data
				poster.detail = res.data
				poster.detail.shareRefereeId = userInfo.value.id
				let cans = `${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&data1=${posterAll.poster_5.id}&studioId=${posterAll.poster_5.studioId}&text=wx&type=5`
				shareMsg.path = `/pages/shareRefereeId/index?q=${encodeURIComponent(cans)}`
				shareMsg.imageUrl = poster.detail.goods.thumPic
		
		
			}
		},
		poster_6: {
			showBtn: ['save', 'wechat'],
			id:'',
			getDetail: async () => {
				const res: any = await api({
					method: "get",
					url:  `/mall/shopping/goods/details/${posterAll.poster_6.id}`,
				});
				poster.detail = res.data
				poster.detail = res.data
				poster.detail.shareRefereeId = userInfo.value.id
				let cans = `${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&goodsId=${posterAll.poster_6.id}&text=wx&type=10`
				shareMsg.path = `/pages/shareRefereeId/index?q=${encodeURIComponent(cans)}`
				shareMsg.imageUrl = poster.detail.thumPic
		
		
			}
		},
		poster_7: {
			showBtn: ['save', 'wechat'],
			id:'',
			getDetail: async () => {
				const res: any = await api({
					method: "get",
					url:  `/mall/content/getShareContent`,
				});
				poster.detail = res.data
				poster.detail.shareRefereeId = userInfo.value.id
				let cans = `${config.api}/?xcx=xjs&shareRefereeId=${poster.detail.shareRefereeId}&goodsId=${posterAll.poster_6.id}&text=wx&type=12`
				shareMsg.path = `/pages/shareRefereeId/index?q=${encodeURIComponent(cans)}`
				shareMsg.imageUrl = poster.detail.thumPic
			}
		},
	})
	const poster = reactive<any>({
		showBtn: [],
		currentPoster: "",
		path: "",
		copyUrl: "",
		detail: {},
		shareItems: [
			//#ifdef MP-WEIXIN
			{
				icon: 'https://xjs-oss-prod.oss-cn-shenzhen.aliyuncs.com/xjs-static/icon-80.png',
				text: '微信好友',
				action: 'wechat'
			},
			// {
			// 	icon: 'https://xjs-oss-prod.oss-cn-shenzhen.aliyuncs.com/xjs-static/icon-80.png',
			// 	text: '朋友圈',
			// 	action: 'timeline'
			// },
			//#endif
			{
				icon: 'https://xjs-oss-prod.oss-cn-shenzhen.aliyuncs.com/xjs-static/icon-82.png',
				text: '保存海报',
				action: 'save'
			}
		],
		getImg: (e) => {
			poster.path = e
			uni.showToast({
				title: '操作成功'
			})
		}
	})
	//分享事件
	const handleShare = async (item) => {
		if (item.action == 'timeline') {
			// wx.shareToTimeline({
			// 	title: '分享到朋友圈',
			// 	link: '你的小程序链接',
			// 	imgUrl: '你的图片链接',
			// 	success: function () {
			// 		console.log('分享到朋友圈成功');
			// 	},
			// 	fail: function (err) {
			// 		console.log('分享到朋友圈失败', err);
			// 	}
			// });

			return
		}
		// let permisRes = await permissionGet({code:'scope.album',message: '需要获取写入相册的权限，是否前往授权？'});
		// console.log(permisRes)
		uni.showLoading({
			mask: true,
			title: '保存中'
		})
		let path:any = ""
		// #ifdef APP
		const status = await accredit('READ_EXTERNAL_STORAGE')
		if (status != 1) return
		path = poster.path
		// #endif
		// #ifndef APP
		path = await getTempFilePath(poster.path)
		// #endif
		uni.saveImageToPhotosAlbum({
			filePath: path,
			success: () => {
				uni.showToast({
					title: '保存成功',
					icon: 'success'
				});
			},
			fail: (error) => {
				uni.showToast({
					title: '保存失败: ' + error.errMsg,
					icon: 'none'
				});
			}
		});
	}
	// 将base64转临时路劲
	const getTempFilePath = (base64Data) => {
		return new Promise((resolve, reject) => {
			const fs = uni.getFileSystemManager()
			base64Data = base64Data.split(',')[1]
			const fileName = 'temp_image_' + Date.now() + '.png' // 自定义文件名，可根据需要修改
			const filePath = uni.env.USER_DATA_PATH + '/' + fileName
			const buffer = uni.base64ToArrayBuffer(base64Data)
			fs.writeFile({
				filePath,
				data: buffer,
				encoding: 'binary',
				success: res => resolve(filePath),
				fail: err => reject(err)
			})
		});
	}
</script>

<style lang="scss" scoped>
	.container {
		padding: 42rpx calc((100vw - 680rpx)/2);
		box-sizing: border-box;

		.container {
			display: flex;
			flex-direction: column;
			align-items: center;
			padding: 30rpx 50rpx;
		}

		.share-panel {
			width: 100%;
			display: flex;
			justify-content: space-around;
			align-items: center;
			padding: 20rpx 40rpx;
		}

		.share-item {
			display: flex;
			flex-direction: column;
			align-items: center;
			gap: 12rpx;
			position: relative;

			.share-button {
				position: absolute;
				width: 88rpx;
				height: 120rpx;
				opacity: 0;
				left: 0;
				top: 0;
			}
		}

		.icon-wrapper {
			width: 88rpx;
			height: 88rpx;
			border-radius: 50%;
             
			>image {
				width: 88rpx;
				height: 88rpx;
				border-radius: 50%;
			}
		}

		.share-text {
			font-size: 12px;
			color: #333333;
			line-height: 1.4;
		}
	}
</style>